home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 October: Technology Seed / ADC Seed CD - October 1999.toast / FireWire / FireWire_2.1_SDK_DR3 / Source / FWIM / PeleFWIM / PeleFWIM.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-17  |  37.0 KB  |  1,164 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PeleFWIM.h
  3.  
  4.     Contains:    Definitions for Pele 1394 card FireWire interface module.
  5.  
  6.     Written by:    Eric W. Anderson
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.        <FW2>      6/5/96    EA        Fill in contains and written by fields.
  13.        <FW1>      6/5/96    EA        first checked in
  14.  
  15. */
  16.  
  17. #ifndef __PELEFWIM__
  18. #define __PELEFWIM__
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23. #ifndef __INTERRUPTS__
  24. #include <Interrupts.h>
  25. #endif
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. #if PRAGMA_IMPORT_SUPPORTED
  32. #pragma import on
  33. #endif
  34.  
  35. #if PRAGMA_ALIGN_SUPPORTED
  36. #pragma options align=power
  37. #endif
  38.  
  39. /*zzz*/
  40. /* Isn't this PCI standard stuff?  Shouldn't it be in some regular include */
  41. /* file like PCI.h? */
  42.  
  43. #define bit0            0x00000001
  44. #define bit1            0x00000002
  45. #define bit2            0x00000004
  46. #define bit3            0x00000008
  47. #define bit4            0x00000010
  48. #define bit5            0x00000020
  49. #define bit6            0x00000040
  50. #define bit7            0x00000080
  51. #define bit8            0x00000100
  52. #define bit9            0x00000200
  53. #define bit10            0x00000400
  54. #define bit11            0x00000800
  55. #define bit12            0x00001000
  56. #define bit13            0x00002000
  57. #define bit14            0x00004000
  58. #define bit15            0x00008000
  59. #define bit16            0x00010000
  60. #define bit17            0x00020000
  61. #define bit18            0x00040000
  62. #define bit19            0x00080000
  63. #define bit20            0x00100000
  64. #define bit21            0x00200000
  65. #define bit22            0x00400000
  66. #define bit23            0x00800000
  67. #define bit24            0x01000000
  68. #define bit25            0x02000000
  69. #define bit26            0x04000000
  70. #define bit27            0x08000000
  71. #define bit28            0x10000000
  72. #define bit29            0x20000000
  73. #define bit30            0x40000000
  74. #define bit31            0x80000000
  75.  
  76. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  77.  * Configuration Registers
  78.  *
  79.  */
  80. enum {
  81.     kConfigStart        = 0x00,
  82.     cwVendorID            = 0x00,            /* 0x1000                                    */
  83.     cwDeviceID            = 0x02,            /* 0x0003                                    */
  84.     cwCommand            = 0x04,
  85.     cwStatus            = 0x06,
  86.     clClassCodeAndRevID    = 0x08,
  87.     clHeaderAndLatency    = 0x0C,
  88.     clBaseAddressZero    = 0x10,            /* I/O Base address                            */
  89.     clBaseAddressOne    = 0x14,            /* Memory Base address                        */
  90.     clExpansionRomAddr    = 0x30,
  91.     clLatGntIntPinLine    = 0x3C,            /* Max_Lat, Max_Gnt, Int. Pin, Int. Line    */
  92.     kConfigEnd            = 0x40
  93. };
  94.  
  95. /*
  96.  * 0x04 cwCommand                    Command Register (read/write)
  97.  */
  98. enum {
  99.     cwCommandSERREnable            = bit8,
  100.     cwCommandEnableParityError    = bit6,
  101.     cwCommandEnableBusMaster    = bit2,        /* Set this on initialization            */
  102.     cwCommandEnableMemorySpace    = bit1,        /* Respond at Base Address One if set    */
  103.     cwCommandEnableIOSpace        = bit0        /* Respond at Base Address Zero if set    */
  104. };
  105. /*
  106.  * 0x06 cwStatus                    Status Register (read/write)
  107.  */
  108. enum {
  109.     cwStatusDetectedParityError    = bit15,    /* Detected from slave                    */
  110.     cwStatusSignaledSystemError = bit14,    /* Device asserts SERR/ signal            */
  111.     cwStatusMasterAbort             = bit13,    /* Master sets when transaction aborts    */
  112.     cwStatusReceivedTargetAbort    = bit12,    /* Master sets when target-abort        */
  113.     cwStatusDEVSELTimingMask    = (bit10 | bit9),    /* DEVSEL timing encoding R/O    */
  114.     cwStatusDEVSELFastTiming    = 0,
  115.     cwStatusDEVSELMediumTiming    = bit9,
  116.     cwStatusDEVSELSlowTiming    = bit10,
  117.     cwStatusDataParityReported    = bit8
  118. };
  119.  
  120. /*zzz*/
  121.  
  122.  
  123. ////////////////////////////////////////////////////////////////////////////////
  124. //
  125. // Useful macro def.
  126. //   This is useful for swapping constants (compiler will simplify).
  127. //   This may be faster for swapping variables.
  128. //   Do not use on expressions with side effects (e.g. function calls)
  129. //
  130.  
  131. #define EndianSwapImm32Bit(data32)                    \
  132. (                                                    \
  133.     (((UInt32) data32) >> 24)                |        \
  134.     ((((UInt32) data32) >> 8) & 0xFF00)        |        \
  135.     ((((UInt32) data32) << 8) & 0xFF0000)    |        \
  136.     (((UInt32) data32) << 24)                        \
  137. )
  138.  
  139.  
  140.  
  141. ////////////////////////////////////////////////////////////////////////////////
  142. //
  143. // FWIM data defs.
  144. //
  145.  
  146. enum
  147. {
  148. //    kAsynchDMA                    = 0,        // Channels we chose...
  149. // Need to clean up a little, these are Lynx numbers:
  150.     kIsochReceiveDMA            = 2,        //
  151.     kIsochTransmitDMA            = 3,        //
  152. //    kTransmitDMA                = 4,        // Lowest priority (would rather receive)
  153.  
  154. // Used in PeleFWIM.h, clean up
  155.     kNumDMAChannels                = 5,        // Number of DMA channels.
  156.  
  157. // Use these intead
  158.     kPeleDMAAsynchTx            = 0,        // Channel numbers from Table 3-2
  159.     kPeleDMAAsynchRx            = 1,        // Used for callProc interrupts, etc.
  160.     kPeleDMAIsochTxA            = 2,
  161.     kPeleDMAIsochTxB            = 3,
  162.     kPeleDMAIsochRxA            = 4,
  163.     kPeleDMAIsochRxB            = 5,
  164.     kPeleDMACount                = 6,
  165.     
  166. // About 192K could be saved by packing three ~1040-byte receive buffers to a page.
  167. // Another 170K or so could by saved if all async buffers were contiguous.
  168.  
  169.     kAsyncRxPacketBufferSize    = 2048,        // Largest legal asynch packet is 1040
  170.                                             // bytes (200 mb)
  171.                                             // kAsyncRxPacketBufferSize must be multiple of 32
  172.     kMaxBufPage                    = 8,        // Max # of physical pages per packet
  173.     kAsynchTxDoneDMA            = 0,        // Asynch transmit done DMA index.
  174.     kAsynchTxDataDMA            = 2,        // Asynch transmit data DMA index.
  175.     kNumAsynchTxDMAs            = 16,        // Number of DMAs for asynch transmit.
  176.     kAsynchRxOverrunDMA            = 0,        // Asynch receive overrun DMA index.
  177.     kAsynchRxFirstPacketDMA        = 3,        // First asynch receive packet DMA index.
  178.     kAsynchRxLastPacketDMA        = 255,        // Last asynch receive packet DMA index.
  179.     kAsynchRxBufs                = 256,        // # of Asynch bufs
  180.     kPeleNumAsynchRxDMAsToPrime    = 20,
  181. //    kIsochTransmitPort            = 1,        // Transmitting isoch port number.
  182. //    kIsochReceivePort            = 2            // Receiving isoch port number.
  183. };
  184.  
  185.  
  186. // Strictly speaking, the "Pele PHY" is the TI TSB21LV03 200 megabit PHY.
  187. // If Pele is used with another PHY, these constants may (or may not) change.
  188. // These are all the same as the old TI TSB11C01DL PHY from the TI P1394 card.
  189.  
  190. ////////////////////////////////////////////////////////////////////////////////
  191. //
  192. // Phy registers.
  193. //
  194.  
  195. enum
  196. {
  197.     kPelePhyBit0                = (1 << 7),
  198.     kPelePhyBit1                = (1 << 6),
  199.     kPelePhyBit2                = (1 << 5),
  200.     kPelePhyBit3                = (1 << 4),
  201.     kPelePhyBit4                = (1 << 3),
  202.     kPelePhyBit5                = (1 << 2),
  203.     kPelePhyBit6                = (1 << 1),
  204.     kPelePhyBit7                = (1 << 0)
  205. };
  206.  
  207. #define PelePhyBitRange(start, end)                    \
  208. (                                                    \
  209.     (((((UInt32) 0xFF) << (start)) & 0xFF) >>        \
  210.      ((start) + (7 - (end)))) <<                    \
  211.     (7 - (end))                                        \
  212. )
  213.  
  214. #define PelePhyBitRangePhase(start, end)            \
  215.     (7 - end)
  216.  
  217. // Phy register defs, as per 1394-1995
  218.  
  219. enum
  220. {
  221.     kPelePhyPhysicalIDAddress    = 0,
  222.     kPelePhyPhysicalID            = PelePhyBitRange (0, 5),
  223.     kPelePhyPhysicalIDPhase        = PelePhyBitRangePhase (0, 5),
  224.  
  225.     kPelePhyRAddress            = 0,
  226.     kPelePhyR                    = kPelePhyBit6,
  227.  
  228.     kPelePhyCPSAddress            = 0,
  229.     kPelePhyCPS                    = kPelePhyBit7,
  230.  
  231.     kPelePhyRHBAddress            = 1,
  232.     kPelePhyRHB                    = kPelePhyBit0,
  233.  
  234.     kPelePhyIBRAddress            = 1,
  235.     kPelePhyIBR                    = kPelePhyBit1,
  236.  
  237.     kPelePhyGCAddress            = 1,
  238.     kPelePhyGC                    = PelePhyBitRange (2, 7),
  239.     kPelePhyGCPhase                = PelePhyBitRangePhase (2, 7),
  240.  
  241.     kPelePhySPDAddress            = 2,
  242.     kPelePhySPD                    = PelePhyBitRange (0, 1),
  243.     kPelePhySPDPhase            = PelePhyBitRangePhase (0, 1),
  244.  
  245.     kPelePhyNPAddress            = 2,
  246.     kPelePhyNP                    = PelePhyBitRange (3, 7),
  247.     kPelePhyNPPhase                = PelePhyBitRangePhase (3, 7),
  248.  
  249.     kPelePhyAStat1Address        = 3,
  250.     kPelePhyAStat1                = PelePhyBitRange (0, 1),
  251.     kPelePhyAStat1Phase            = PelePhyBitRangePhase (0, 1),
  252.  
  253.     kPelePhyBStat1Address        = 3,
  254.     kPelePhyBStat1                = PelePhyBitRange (2, 3),
  255.     kPelePhyBStat1Phase            = PelePhyBitRangePhase (2, 3),
  256.  
  257.     kPelePhyPortStatus1Address    = 3,
  258.     kPelePhyPortStatus1            = PelePhyBitRange (4, 5),
  259.     kPelePhyPortStatus1Phase    = PelePhyBitRangePhase (4, 5),
  260.  
  261.     kPelePhyCh1Address            = 3,
  262.     kPelePhyCh1                    = kPelePhyBit4,
  263.  
  264.     kPelePhyCon1Address            = 3,
  265.     kPelePhyCon1                = kPelePhyBit5,
  266.  
  267.     kPelePhyAStat2Address        = 4,
  268.     kPelePhyAStat2                = PelePhyBitRange (0, 1),
  269.     kPelePhyAStat2Phase            = PelePhyBitRangePhase (0, 1),
  270.  
  271.     kPelePhyBStat2Address        = 4,
  272.     kPelePhyBStat2                = PelePhyBitRange (2, 3),
  273.     kPelePhyBStat2Phase            = PelePhyBitRangePhase (2, 3),
  274.  
  275.     kPelePhyPortStatus2Address    = 4,
  276.     kPelePhyPortStatus2            = PelePhyBitRange (4, 5),
  277.     kPelePhyPortStatus2Phase    = PelePhyBitRangePhase (4, 5),
  278.  
  279.     kPelePhyCh2Address            = 4,
  280.     kPelePhyCh2                    = kPelePhyBit4,
  281.  
  282.     kPelePhyCon2Address            = 4,
  283.     kPelePhyCon2                = kPelePhyBit5,
  284.  
  285.     kPelePhyAStat3Address        = 5,
  286.     kPelePhyAStat3                = PelePhyBitRange (0, 1),
  287.     kPelePhyAStat3Phase            = PelePhyBitRangePhase (0, 1),
  288.  
  289.     kPelePhyBStat3Address        = 5,
  290.     kPelePhyBStat3                = PelePhyBitRange (2, 3),
  291.     kPelePhyBStat3Phase            = PelePhyBitRangePhase (2, 3),
  292.  
  293.     kPelePhyPortStatus3Address    = 5,
  294.     kPelePhyPortStatus3            = PelePhyBitRange (4, 5),
  295.     kPelePhyPortStatus3Phase    = PelePhyBitRangePhase (4, 5),
  296.  
  297.     kPelePhyCh3Address            = 5,
  298.     kPelePhyCh3                    = kPelePhyBit4,
  299.  
  300.     kPelePhyCon3Address            = 5,
  301.     kPelePhyCon3                = kPelePhyBit5,
  302.  
  303.     kPelePhyCAddress            = 6,
  304.     kPelePhyC                    = kPelePhyBit7,
  305.  
  306.     kPelePhyInvalidAddress        = 15
  307. };
  308.  
  309.  
  310.  
  311. ////////////////////////////////////////////////////////////////////////////////
  312. //
  313. // Pele registers.  Based on the 0.93v0 spec
  314. //
  315.  
  316. // This struct matches struct DBDMAChannelRegisters from DBDMA.h, except that
  317. // the Pele one is cut short (just 32 bytes).  There is one of these for each
  318. // of the 6 DMA channels (Asynch xmit/rcv, Iso xmit A/B, Iso rcv A/B).  Also,
  319. // except for Asynch transmit, the Select registers aren't implemented in Pele.
  320.  
  321. struct PeleDBDMAChannelRegistersStruct
  322. {
  323.     volatile UInt32                channelControl;
  324.     volatile UInt32                channelStatus;
  325.     volatile UInt32                reserved8;
  326.     volatile UInt32                commandPtr;
  327.     volatile UInt32                interruptSelect;        // Asynch xmit only
  328.     volatile UInt32                branchSelect;            // Asynch xmit only
  329.     volatile UInt32                waitSelect;                // Asynch xmit only
  330.     volatile UInt32                reserved1C;
  331. };
  332. typedef struct PeleDBDMAChannelRegistersStruct
  333.                                 PeleDBDMAChannelRegisters,
  334.                                 *PeleDBDMAChannelRegistersPtr;
  335.  
  336.  
  337. // This is Pele-specific, and controls Isoch functions (like start-on-cycle).
  338. // The bandwidthControl is transmit only.
  339. // There are four of these, one each for Iso xmit A/B and rcv A/B.
  340.  
  341. struct PeleIsochControlRegistersStruct
  342. {
  343.     volatile UInt32                eventCycle;
  344.     volatile UInt32                configuration;
  345.     volatile UInt32                bandwidthControl;        // Xmit only
  346.     volatile UInt32                reservedC;
  347. };
  348. typedef struct PeleIsochControlRegistersStruct
  349.                                 PeleIsochControlRegisters,
  350.                                 *PeleIsochControlRegistersPtr;
  351.  
  352. // This is not a register; this is the DBDMA command program element.
  353. // String these together in main memory and give Pele the address to run from.
  354.  
  355. struct PeleDBDMADescriptor
  356. {
  357.     unsigned long                operation;
  358.     unsigned long                address;
  359.     unsigned long                cmdDep;
  360.     unsigned long                result;
  361. };
  362. typedef struct PeleDBDMADescriptor
  363.                                 PeleDBDMADescriptor,
  364.                                 PeleDMA,                    // shorthand
  365.                                 *PeleDBDMADescriptorPtr,
  366.                                 *PeleDMAPtr;                // shorthand
  367.  
  368.  
  369. // This is the main Pele register file, 512 bytes long.  Note that unlike
  370. // some other 1394 chips, the PCI control registers aren't included here.
  371.  
  372. struct PeleRegistersStruct
  373. {
  374.     PeleDBDMAChannelRegisters    asynchTransmit;
  375.     PeleDBDMAChannelRegisters    asynchReceive;
  376.     PeleDBDMAChannelRegisters    isochTransmitA;
  377.     PeleDBDMAChannelRegisters    isochTransmitB;
  378.     PeleDBDMAChannelRegisters    isochReceiveA;
  379.     PeleDBDMAChannelRegisters    isochReceiveB;
  380.     volatile UInt32                reservedC0[16];
  381.     volatile UInt32                version;
  382.     volatile UInt32                control;
  383.     volatile UInt32                nodeID;
  384.     volatile UInt32                reset;
  385.     volatile UInt32                packetControl;
  386.     volatile UInt32                diagnosticStatus;
  387.     volatile UInt32                phyControl;
  388.     volatile UInt32                atRetries;
  389.     volatile UInt32                ssnInterface;
  390.     volatile UInt32                isochronousCycleTimer;
  391.     volatile UInt32                reserved128[2];
  392.     PeleIsochControlRegisters    itaControl;
  393.     PeleIsochControlRegisters    itbControl;
  394.     PeleIsochControlRegisters    iraControl;
  395.     PeleIsochControlRegisters    irbControl;
  396.     volatile UInt32                rsuEnable;
  397.     volatile UInt32                rsuInterrupt;
  398.     volatile UInt32                rsuTablePtr;
  399.     volatile UInt32                rsuInterruptSet;
  400.     volatile UInt32                interruptEvents;
  401.     volatile UInt32                interruptMask;
  402.     volatile UInt32                interruptClear;
  403.     volatile UInt32                interruptLevels;
  404.     volatile UInt32                reserved190[4];
  405.     volatile UInt32                fifoFlags;
  406.     volatile UInt32                fifoStatus;
  407. };
  408. typedef struct PeleRegistersStruct
  409.                                 PeleRegisters,
  410.                                 *PeleRegistersPtr;
  411.  
  412. // Bit definitions for Pele register contents and Pele-specific data formatting
  413.  
  414. enum
  415. {
  416.     kPeleBit0                    = (1 << 0),
  417.     kPeleBit1                    = (1 << 1),
  418.     kPeleBit2                    = (1 << 2),
  419.     kPeleBit3                    = (1 << 3),
  420.     kPeleBit4                    = (1 << 4),
  421.     kPeleBit5                    = (1 << 5),
  422.     kPeleBit6                    = (1 << 6),
  423.     kPeleBit7                    = (1 << 7),
  424.     kPeleBit8                    = (1 << 8),
  425.     kPeleBit9                    = (1 << 9),
  426.     kPeleBit10                    = (1 << 10),
  427.     kPeleBit11                    = (1 << 11),
  428.     kPeleBit12                    = (1 << 12),
  429.     kPeleBit13                    = (1 << 13),
  430.     kPeleBit14                    = (1 << 14),
  431.     kPeleBit15                    = (1 << 15),
  432.     kPeleBit16                    = (1 << 16),
  433.     kPeleBit17                    = (1 << 17),
  434.     kPeleBit18                    = (1 << 18),
  435.     kPeleBit19                    = (1 << 19),
  436.     kPeleBit20                    = (1 << 20),
  437.     kPeleBit21                    = (1 << 21),
  438.     kPeleBit22                    = (1 << 22),
  439.     kPeleBit23                    = (1 << 23),
  440.     kPeleBit24                    = (1 << 24),
  441.     kPeleBit25                    = (1 << 25),
  442.     kPeleBit26                    = (1 << 26),
  443.     kPeleBit27                    = (1 << 27),
  444.     kPeleBit28                    = (1 << 28),
  445.     kPeleBit29                    = (1 << 29),
  446.     kPeleBit30                    = (1 << 30),
  447.     kPeleBit31                    = (1 << 31)
  448. };
  449.  
  450. #define PeleBitRange(start, end)                    \
  451. (                                                    \
  452.     ((((UInt32) 0xFFFFFFFF) << (31 - (end))) >>        \
  453.      ((31 - (end)) + (start))) <<                    \
  454.     (start)                                            \
  455. )
  456.  
  457. #define PeleBitRangePhase(start, end)                \
  458.     (start)
  459.  
  460.  
  461. // Link Data Format defs.  Although these are mostly 1394 constants, there can
  462. // be some FWIM-specific variations, so these are all included here.
  463.  
  464. enum
  465. {
  466.     kPeleDMA100mbps                = 0,
  467.     kPeleDMA200mbps                = 1,
  468.     kPeleDMA400mbps                = 2
  469. };
  470.  
  471. enum
  472. {
  473.     // This is a value that Pele puts in the tCode position of the "header"
  474.     // of the packet formed by concatenating all of the self ID packets.
  475.     // This tCode isn't defined in 1394, but if it ever is, Pele won't
  476.     // receive it, because the Link won't know how to process the CRC or
  477.     // header.  So we'll never get this "tCode", except for self-IDs.
  478.     
  479.     kPeleTCodeSelfID            = 0x0E
  480. };
  481.  
  482. enum
  483. {
  484.     kPelePacketPrio                            = PeleBitRange (0, 3),
  485.     kPelePacketPrioPhase                    = PeleBitRangePhase (0, 3),
  486.     kPelePacketTCode                        = PeleBitRange (4, 7),
  487.     kPelePacketTCodePhase                    = PeleBitRangePhase (4, 7),
  488.     kPelePacketSpd                            = PeleBitRange (16, 17),
  489.     kPelePacketSpdPhase                        = PeleBitRangePhase (16, 17),
  490.     kPelePacketEnableAT                        = kPeleBit19,
  491.     kPelePacketAckSent                        = PeleBitRange (0, 3),
  492.     kPelePacketAckSentPhase                    = PeleBitRangePhase (0, 3)
  493. };
  494.  
  495. enum
  496. {
  497.     kPeleAsynchTLabel                        = PeleBitRange (10, 15),
  498.     kPeleAsynchTLabelPhase                    = PeleBitRangePhase (10, 15),
  499.  
  500.     kPeleAsynchRt                            = PeleBitRange (8, 9),
  501.     kPeleAsynchRtPhase                        = PeleBitRangePhase (8, 9),
  502.     kPeleAsynchNew                            = 0,
  503.     kPeleAsynchRetryA                        = 2,
  504.     kPeleAsynchRetryB                        = 3,
  505.  
  506.     kPeleAsynchPriority                        = PeleBitRange (0, 3),
  507.     kPeleAsynchPriorityPhase                = PeleBitRangePhase (0, 3),
  508.  
  509.     kPeleAsynchDestinationID                = PeleBitRange (16, 31),
  510.     kPeleAsynchDestinationIDPhase            = PeleBitRangePhase (16, 31),
  511.  
  512.     kPeleAsynchSourceID                        = PeleBitRange (16, 31),
  513.     kPeleAsynchSourceIDPhase                = PeleBitRangePhase (16, 31),
  514.  
  515.     kPeleAsynchDestinationOffsetHigh        = PeleBitRange (0, 15),
  516.     kPeleAsynchDestinationOffsetHighPhase    = PeleBitRangePhase (0, 15),
  517.  
  518.     kPeleAsynchDestinationOffsetLow            = PeleBitRange (0, 31),
  519.     kPeleAsynchDestinationOffsetLowPhase    = PeleBitRangePhase (0, 31),
  520.  
  521.     kPeleAsynchDataLength                    = PeleBitRange (16, 31),
  522.     kPeleAsynchDataLengthPhase                = PeleBitRangePhase (16, 31),
  523.  
  524.     kPeleAsynchExtendedTCode                = PeleBitRange (0, 15),
  525.     kPeleAsynchExtendedTCodePhase            = PeleBitRangePhase (0, 15),
  526.  
  527.     kPeleAsynchAckSent                        = PeleBitRange (0, 3),
  528.     kPeleAsynchAckSentPhase                    = PeleBitRangePhase (0, 3),
  529.  
  530.     kPeleAsynchRCode                        = PeleBitRange (12, 15),
  531.     kPeleAsynchRCodePhase                    = PeleBitRangePhase (12, 15)
  532. };
  533.  
  534.  
  535.  
  536. ////////////////////////////////////////////////////////////////////////////////
  537. //
  538. // Pele register-specific constants.
  539. //
  540.  
  541. // These apply to all of the DBDMA channels
  542.  
  543. enum
  544. {
  545.     kPeleSetRun                    = 0x80008000,
  546.     kPeleClrRun                    = 0x80000000,
  547.     kPeleSetPause                = 0x40004000,
  548.     kPeleClrPause                = 0x40000000,
  549.     kPeleSetFlush                = 0x20002000,
  550.     kPeleSetWake                = 0x10001000,
  551.     kPeleClrDead                = 0x08000000,
  552.     kPeleSetS7                    = 0x00800080,
  553.     kPeleClrS7                    = 0x00800000,
  554.     kPeleSetS6                    = 0x00400040,
  555.     kPeleClrS6                    = 0x00400000,
  556.     kPeleSetS5                    = 0x00200020,
  557.     kPeleClrS5                    = 0x00200000,
  558.     kPeleSetS4                    = 0x00100010,
  559.     kPeleClrS4                    = 0x00100000,
  560.     kPeleSetS3                    = 0x00080008,
  561.     kPeleClrS3                    = 0x00080000,
  562.     kPeleSetS2                    = 0x00040004,
  563.     kPeleClrS2                    = 0x00040000,
  564.     kPeleSetS1                    = 0x00020002,
  565.     kPeleClrS1                    = 0x00020000,
  566.     kPeleSetS0                    = 0x00010001,
  567.     kPeleClrS0                    = 0x00010000,
  568.     kPeleClrAll                    = 0xFFFF0000
  569. };
  570.  
  571. enum
  572. {
  573.     kPeleRun                    = 0x00008000,
  574.     kPelePause                    = 0x00004000,
  575.     kPeleFlush                    = 0x00002000,
  576.     kPeleWake                    = 0x00001000,
  577.     kPeleDead                    = 0x00000800,
  578.     kPeleActive                    = 0x00000400,
  579.     kPeleBt                        = 0x00000100,
  580.     kPeleS7                        = 0x00000080,
  581.     kPeleS6                        = 0x00000040,
  582.     kPeleS5                        = 0x00000020,
  583.     kPeleS4                        = 0x00000010,
  584.     kPeleS3                        = 0x00000008,
  585.     kPeleS2                        = 0x00000004,
  586.     kPeleS1                        = 0x00000002,
  587.     kPeleS0                        = 0x00000001
  588. };
  589.  
  590. enum
  591. {
  592.     kPeleOUTPUT_MORE            = 0x00000000,
  593.     kPeleOUTPUT_LAST            = 0x10000000,
  594.     kPeleINPUT_MORE                = 0x20000000,
  595.     kPeleINPUT_LAST                = 0x30000000,
  596.     kPeleSTORE_QUAD                = 0x40000000,
  597.     kPeleLOAD_QUAD                = 0x50000000,
  598.     kPeleNOP_CMD                = 0x60000000,
  599.     kPeleSTOP_CMD                = 0x70000000,
  600.     kPeleCmdMask                = 0xF0000000
  601. };
  602.  
  603. enum
  604. {
  605.     kPeleKEY_STREAM0            = 0x00000000,
  606.     kPeleKEY_STREAM1            = 0x01000000,
  607.     kPeleKEY_STREAM2            = 0x02000000,
  608.     kPeleKEY_STREAM3            = 0x03000000,
  609.     kPeleKEY_REGS                = 0x05000000,
  610.     kPeleKEY_SYSTEM                = 0x06000000,
  611.     kPeleKEY_DEVICE                = 0x07000000,
  612.     kPeleKeyMask                = 0x07000000,
  613.     kPeleIntNever                = 0x00000000,
  614.     kPeleIntIfTrue                = 0x00100000,
  615.     kPeleIntIfFalse                = 0x00200000,
  616.     kPeleIntAlways                = 0x00300000,
  617.     kPeleIMask                    = 0x00300000,
  618.     kPeleBranchNever            = 0x00000000,
  619.     kPeleBranchIfTrue            = 0x00040000,
  620.     kPeleBranchIfFalse            = 0x00080000,
  621.     kPeleBranchAlways            = 0x000C0000,
  622.     kPeleBMask                    = 0x000C0000,
  623.     kPeleWaitNever                = 0x00000000,
  624.     kPeleWaitIfTrue                = 0x00010000,
  625.     kPeleWaitIfFalse            = 0x00020000,
  626.     kPeleWaitAlways                = 0x00030000,
  627.     kPeleWMask                    = 0x00030000,
  628.     kPeleCommandMask            = 0xFFFF0000,
  629.     kPeleReqCountMask            = 0x0000FFFF
  630. };
  631.  
  632. enum
  633. {
  634.     kPeleXferStatusRun            = kPeleRun << 16,
  635.     kPeleXferStatusPause        = kPelePause << 16,
  636.     kPeleXferStatusFlush        = kPeleFlush << 16,
  637.     kPeleXferStatusWake            = kPeleWake << 16,
  638.     kPeleXferStatusDead            = kPeleDead << 16,
  639.     kPeleXferStatusActive        = kPeleActive << 16,
  640.     kPeleXferStatusBt            = kPeleBt << 16,
  641.     kPeleXferStatusS7            = kPeleS7 << 16,
  642.     kPeleXferStatusS6            = kPeleS6 << 16,
  643.     kPeleXferStatusS5            = kPeleS5 << 16,
  644.     kPeleXferStatusS4            = kPeleS4 << 16,
  645.     kPeleXferStatusS3            = kPeleS3 << 16,
  646.     kPeleXferStatusS2            = kPeleS2 << 16,
  647.     kPeleXferStatusS1            = kPeleS1 << 16,
  648.     kPeleXferStatusS0            = kPeleS0 << 16,
  649.     kPeleXferStatusMask            = 0xFFFF0000,
  650.     kPeleResCountMask            = 0x0000FFFF
  651. };
  652.  
  653. // Version register [version, 100]
  654.  
  655. enum
  656. {
  657.     kPeleVersionVersion                    = PeleBitRange(16, 31),
  658.     kPeleVersionVersionPhase            = PeleBitRangePhase(16, 31),
  659.     kPeleVersionRevision                = PeleBitRange(0, 15),
  660.     kPeleVersionRevisionPhase            = PeleBitRangePhase(0, 15)
  661. };
  662.  
  663. // Control register [control, 104]
  664.  
  665. enum
  666. {
  667.     kPeleControlByteSwap                = kPeleBit31,            // Formerly "littleEndian"
  668.     kPeleControlPhysDMAEnable            = PeleBitRange(24, 25),
  669.     kPeleControlPhysDMAEnablePhase        = PeleBitRangePhase(24, 25),
  670.     kPeleControlCycleSource                = kPeleBit18,
  671.     kPeleControlCycleMaster                = kPeleBit17,
  672.     kPeleControlCycleTimerEnable        = kPeleBit16,
  673.     kPeleControlStrictIsoch                = kPeleBit8,
  674.     kPeleControlReceiveEnable            = kPeleBit1,
  675.     kPeleControlTransmitEnable            = kPeleBit0,
  676.     
  677.     kPelePhysDMAnoAccess                = 0,
  678.     kPelePhysDMAreadOnly                = 1,
  679.     kPelePhysDMAreadWrite                = 2
  680. };
  681.  
  682. // Node Identification register [nodeID, 108]
  683.  
  684. enum
  685. {
  686.     kPeleNodeIDValid                    = kPeleBit31,
  687.     kPeleNodeIDRoot                        = kPeleBit23,
  688.     kPeleNodeIDFullID                    = PeleBitRange(0, 15),
  689.     kPeleNodeIDFullIDPhase                = PeleBitRangePhase(0, 15),
  690.     kPeleNodeIDBusNumber                = PeleBitRange(6, 15),
  691.     kPeleNodeIDBusNumberPhase            = PeleBitRangePhase(6, 15),
  692.     kPeleNodeIDNodeNumber                = PeleBitRange(0, 5),
  693.     kPeleNodeIDNodeNumberPhase            = PeleBitRangePhase(0, 5)
  694. };
  695.  
  696. // Reset register [reset, 10C]
  697.  
  698. enum
  699. {
  700.     kPeleResetLinkOnEnable                = kPeleBit8,
  701.     kPeleResetReceiver                    = kPeleBit5,
  702.     kPeleResetTransmitter                = kPeleBit4,
  703.     kPeleResetRF                        = kPeleBit2,
  704.     kPeleResetITF                        = kPeleBit1,
  705.     kPeleResetATF                        = kPeleBit0
  706. };
  707.  
  708. // Packet Control register [packetControl, 110]
  709.  
  710. enum
  711. {
  712.     kPelePacketControlPSBusyClr            = kPeleBit17,
  713.     kPelePacketControlPSBusy            = kPeleBit16,
  714.     kPelePacketControlBsyCtrl            = PeleBitRange(8, 10),
  715.     kPelePacketControlBsyCtrlPhase        = PeleBitRangePhase(8, 10),
  716.     kPelePacketControlRcvSelfID            = kPeleBit5,
  717.     kPelePacketControlEnableSnoop        = kPeleBit4,
  718.     
  719.     kPeleBsyCtrlDualPhase                = 0,
  720.     kPeleBsyCtrlSendBusyA                = 1,
  721.     kPeleBsyCtrlSendBusyB                = 2,
  722.     kPeleBsyCtrlSendBusyX                = 3,
  723.     kPeleBsyCtrlAlwaysSendBusyDual        = 4,
  724.     kPeleBsyCtrlAlwaysSendBusyA            = 5,
  725.     kPeleBsyCtrlAlwaysSendBusyB            = 6,
  726.     kPeleBsyCtrlAlwaysSendBusyX            = 7
  727. };
  728.  
  729. // Diagnostic Status register [diagnosticStatus, 114]
  730.  
  731. enum
  732. {
  733.     kPeleDiagIsoActive                    = kPeleBit4,
  734.     kPeleDiagBusyState                    = kPeleBit2,
  735.     kPeleDiagSubactionGap                = kPeleBit1,
  736.     kPeleDiagArbResetGap                = kPeleBit0
  737. };
  738.  
  739. // Phy Control register [phyControl, 118]
  740.  
  741. enum
  742. {
  743.     kPelePhyControlRdDone                = kPeleBit31,
  744.     kPelePhyControlRdAddr                = PeleBitRange(24, 27),
  745.     kPelePhyControlRdAddrPhase            = PeleBitRangePhase(24, 27),
  746.     kPelePhyControlRdData                = PeleBitRange(16, 23),
  747.     kPelePhyControlRdDataPhase            = PeleBitRangePhase(16, 23),
  748.     kPelePhyControlRdReg                = kPeleBit15,
  749.     kPelePhyControlWrReg                = kPeleBit14,
  750.     kPelePhyControlWrAddr                = PeleBitRange(8, 11),
  751.     kPelePhyControlWrAddrPhase            = PeleBitRangePhase(8, 11),
  752.     kPelePhyControlWrData                = PeleBitRange(0, 7),
  753.     kPelePhyControlWrDataPhase            = PeleBitRangePhase(0, 7)
  754. };
  755.  
  756. // ATRetries register [atRetries, 11C]
  757.  
  758. enum
  759. {
  760.     kPeleATRetriesPSRetryCnt            = PeleBitRange(16, 19),
  761.     kPeleATRetriesPSRetryCntPhase        = PeleBitRangePhase(16, 19),
  762.     kPeleATRetriesAsyncRetryCnt            = PeleBitRange(8, 11),
  763.     kPeleATRetriesAsyncRetryCntPhase    = PeleBitRangePhase(8, 11),
  764.     kPeleATRetriesMaxRetries            = PeleBitRange(0, 3),
  765.     kPeleATRetriesMaxRetriesPhase        = PeleBitRangePhase(0, 3)
  766. };
  767.  
  768. // SSN Interface register [ssnInterface, 120]
  769. // Warning, some parts may do this backwards (low=1, tristate=0).
  770.  
  771. enum
  772. {
  773.     kPeleSSNSerialDtIn                    = kPeleBit1,
  774.     kPeleSSNSerialDtOut                    = kPeleBit0,
  775.     
  776.     kPeleSSNOutLow                        = 0,
  777.     kPeleSSNOutTristate                    = kPeleBit0
  778. };
  779.  
  780. // Isochronous Cycle Timer register [isochronousCycleTimer, 124]
  781.  
  782. enum
  783. {
  784.     kPeleICTSeconds                        = PeleBitRange(25, 31),
  785.     kPeleICTSecondsPhase                = PeleBitRangePhase(25, 31),
  786.     kPeleICTCount                        = PeleBitRange(12, 24),
  787.     kPeleICTCountPhase                    = PeleBitRangePhase(12, 24),
  788.     kPeleICTOffset                        = PeleBitRange(0, 11),
  789.     kPeleICTOffsetPhase                    = PeleBitRangePhase(0, 11)
  790. };
  791.  
  792. // Isochronous Event Cycle registers
  793. //   [itaControl.eventCycle, 130]
  794. //   [itbControl.eventCycle, 140]
  795. //   [iraControl.eventCycle, 150]
  796. //   [irbControl.eventCycle, 160]
  797.  
  798. enum
  799. {
  800.     kPeleIsochEventCycle                = PeleBitRange(12, 31),
  801.     kPeleIsochEventCyclePhase            = PeleBitRangePhase(12, 31)
  802. };
  803.  
  804. // IT DMA Configuration registers
  805. //   [itaControl.configuration, 134]
  806. //   [itbControl.configuration, 144]
  807.  
  808. enum
  809. {
  810.     kPeleITDMAconfigTag                    = PeleBitRange(30, 31),
  811.     kPeleITDMAconfigTagPhase            = PeleBitRangePhase(30, 31),
  812.     kPeleITDMAconfigChannel                = PeleBitRange(24, 29),
  813.     kPeleITDMAconfigChannelPhase        = PeleBitRangePhase(24, 29),
  814.     kPeleITDMAconfigSpeed                = PeleBitRange(16, 17),
  815.     kPeleITDMAconfigSpeedPhase            = PeleBitRangePhase(16, 17),
  816.     kPeleITDMAconfigSync                = PeleBitRange(12, 15),
  817.     kPeleITDMAconfigSyncPhase            = PeleBitRangePhase(12, 15),
  818.     kPeleITDMAconfigRateMode            = kPeleBit8,
  819.     kPeleITDMAconfigStartOnEvent        = PeleBitRange(4, 5),
  820.     kPeleITDMAconfigStartOnEventPhase    = PeleBitRangePhase(4, 5),
  821.     kPeleITDMAconfigStopOnEvent            = PeleBitRange(0, 1),
  822.     kPeleITDMAconfigStopOnEventPhase    = PeleBitRangePhase(0, 1)
  823.     
  824.     // See IR DMA for Start/Stop Event codes
  825. };
  826.  
  827. // IT DMA Bandwidth Control resigster (AKA I+N/D)
  828. //   [itaControl.bandwidthControl, 138]
  829. //   [itbControl.bandwidthControl, 148]
  830.  
  831. enum
  832. {
  833.     kPeleITDMABandwidthI                = PeleBitRange(16, 27),
  834.     kPeleITDMABandwidthIPhase            = PeleBitRangePhase(16, 27),
  835.     kPeleITDMABandwidthN                = PeleBitRange(8, 15),
  836.     kPeleITDMABandwidthNPhase            = PeleBitRangePhase(8, 15),
  837.     kPeleITDMABandwidthD                = PeleBitRange(0, 7),
  838.     kPeleITDMABandwidthDPhase            = PeleBitRangePhase(0, 7)
  839. };
  840.  
  841. // IR DMA Configuration registers
  842. //   [iraControl.configuration, 154]
  843. //   [irbControl.configuration, 164]
  844.  
  845. enum
  846. {
  847.     kPeleIRDMAconfigTag                    = PeleBitRange(30, 31),
  848.     kPeleIRDMAconfigTagPhase            = PeleBitRangePhase(30, 31),
  849.     kPeleIRDMAconfigChannel                = PeleBitRange(24, 29),
  850.     kPeleIRDMAconfigChannelPhase        = PeleBitRangePhase(24, 29),
  851.     kPeleIRDMAconfigSync                = PeleBitRange(12, 15),
  852.     kPeleIRDMAconfigSyncPhase            = PeleBitRangePhase(12, 15),
  853.     kPeleIRDMAconfigBufferMode            = kPeleBit8,
  854.     kPeleIRDMAconfigStartOnEvent        = PeleBitRange(4, 5),
  855.     kPeleIRDMAconfigStartOnEventPhase    = PeleBitRangePhase(4, 5),
  856.     kPeleIRDMAconfigStopOnEvent            = PeleBitRange(0, 1),
  857.     kPeleIRDMAconfigStopOnEventPhase    = PeleBitRangePhase(0, 1),
  858.     
  859.     kPeleEventChannelProgram            = 0,
  860.     kPeleEventCycleNumber                = 1,
  861.     kPeleEventSync                        = 2,
  862.     kPeleEventOccured                    = 3
  863. };
  864.  
  865. // Read Response registers
  866. //   [rsuEnable, 170]
  867. //   [rsuInterrupt, 174]
  868. //   [rsuTablePtr, 178]
  869. //   [rsuInterruptSet, 17C]
  870. // There's nothing to enum for these
  871.  
  872. // Interrupt Events, Mask, Level, and Clear registers
  873. //   [interruptEvents, 180]
  874. //   [interruptMask, 184]
  875. //   [interruptClear, 188]
  876. //   [interruptLevels, 18C]
  877.  
  878. enum
  879. {
  880.     kPeleIntITBadFormat                    = kPeleBit31,        // Spec lists these in
  881.     kPeleIntPhyRegRcvd                    = kPeleBit30,        // reverse order, unlike
  882.     kPeleIntCycleTooLong                = kPeleBit29,        // all other registers.
  883.     kPeleIntPSOutOfRetries                = kPeleBit28,
  884.     kPeleIntRSDone                        = kPeleBit27,        // Here they are listed
  885.     kPeleIntRSXferErr                    = kPeleBit26,        // in "natural" order, ie,
  886.     kPeleIntPWQUxferErr                    = kPeleBit25,        // left-to-right.
  887.     kPeleIntPRQUxferErr                    = kPeleBit24,
  888.     kPeleIntTCodeErr                    = kPeleBit23,
  889.     kPeleIntHdrErr                        = kPeleBit22,
  890.     kPeleIntSentRej                        = kPeleBit21,
  891.     kPeleIntATBadFormat                    = kPeleBit20,
  892.     kPeleIntCycleLost                    = kPeleBit19,
  893.     kPeleIntCycleSeconds                = kPeleBit18,
  894.     kPeleIntCycleStart                    = kPeleBit17,
  895.     kPeleIntTxRdy                        = kPeleBit16,
  896.     kPeleIntRcvData                        = kPeleBit15,
  897.     kPeleIntPhyInt                        = kPeleBit14,
  898.     kPeleIntCmdReset                    = kPeleBit13,
  899.     kPeleIntBusReset                    = kPeleBit12,
  900.     kPeleIntCycleEventIRB                = kPeleBit11,
  901.     kPeleIntCycleEventIRA                = kPeleBit10,
  902.     kPeleIntCycleEventITB                = kPeleBit9,
  903.     kPeleIntCycleEventITA                = kPeleBit8,
  904.     kPeleIntDMAIRB                        = kPeleBit5,
  905.     kPeleIntDMAIRA                        = kPeleBit4,
  906.     kPeleIntDMAITB                        = kPeleBit3,
  907.     kPeleIntDMAITA                        = kPeleBit2,
  908.     kPeleIntDMAAR                        = kPeleBit1,
  909.     kPeleIntDMAAT                        = kPeleBit0
  910. };
  911.  
  912. // FIFO Flags Register [fifoFlags, 1A0]
  913. // Warning, may not exist in some Pele parts
  914.  
  915. enum
  916. {
  917.     kPeleFifoRcvFull                    = kPeleBit18,
  918.     kPeleFifoRcvAlFull                    = kPeleBit17,
  919.     kPeleFifoRcvEmpty                    = kPeleBit16,
  920.     kPeleFifoIsochTxFull                = kPeleBit10,
  921.     kPeleFifoIsochTxAlFull                = kPeleBit9,
  922.     kPeleFifoIsochTxEmpty                = kPeleBit8,
  923.     kPeleFifoAsynchTxFull                = kPeleBit2,
  924.     kPeleFifoAsynchTxAlFull                = kPeleBit1,
  925.     kPeleFifoAsynchTxEmpty                = kPeleBit0
  926. };
  927.  
  928. // FIFO Status Register [fifoStatus, 1A4]
  929. // Warning, may not exist in some Pele parts
  930.  
  931. enum
  932. {
  933.     kPeleFifoRcvPtr                        = PeleBitRange(24, 30),
  934.     kPeleFifoRcvPtrPhase                = PeleBitRangePhase(24, 30),
  935.     kPeleFifoIsochTxPtr                    = PeleBitRange(16, 22),
  936.     kPeleFifoIsochTxPtrPhase            = PeleBitRangePhase(16, 22),
  937.     kPeleFifoAsynchTxPtr                = PeleBitRange(8, 14),
  938.     kPeleFifoAsynchTxPtrPhase            = PeleBitRangePhase(8, 14),
  939.     kPeleFifoRcvWatermark                = kPeleBit2,
  940.     kPeleFifoIsochTxWatermark            = kPeleBit1,
  941.     kPeleFifoAsynchTxWatermark            = kPeleBit0
  942. };
  943.  
  944.  
  945. // Defs for pending FWIM commands.
  946.  
  947. enum
  948. {
  949.     kPelePendingFWIMCommandBusy    = 1
  950. };
  951.  
  952.  
  953. // Various private data structures used within PeleFWIM.
  954.  
  955. struct PeleIsochPortDataStruct
  956. {
  957.     DCLProgramID                dclProgramID,            // ID of DCL program we're using.
  958.                                 originalDCLProgramID,    // Original DCL program ID.
  959.                                 translatedDCLProgramID;    // Translated DCL program ID.
  960.     UInt32                        channelNum;                // Isoch channel number used for this port.
  961.     UInt32                        speed;                    // Speed of this port.
  962.     Boolean                        talking;                // True if port is for talking.
  963. };
  964. typedef struct PeleIsochPortDataStruct
  965.                                 PeleIsochPortData,
  966.                                 *PeleIsochPortDataPtr;
  967.  
  968. // There is one of these structs for each asynch receive buffer/descriptor pair.
  969. // It holds auxillary data, like the asynch processing paramaters.
  970.  
  971. struct PeleAsynchRxDMADataStruct
  972. {
  973.     struct PeleAsynchRxDMADataStruct    *pNextRxDMAData;        // Pointer to next DMA data.
  974.     struct PeleFWIMDataStruct    *pPeleFWIMData;            // Pointer to Pele FWIM data.
  975.     PeleDMAPtr                    pDMA;                    // Logical pointer to descriptor
  976.     Ptr                            pDMAPhysical;            // Physical pointer to descriptor.
  977.     Ptr                            packetBuffer;            // Logical packet buffer of DMA.
  978.     FWIMProcessAsynchParams        fwimProcessAsynchParams;// Params for processing received requests.
  979. };
  980. typedef struct PeleAsynchRxDMADataStruct
  981.                                 PeleAsynchRxDMAData,
  982.                                 *PeleAsynchRxDMADataPtr;
  983.  
  984. struct PeleAsynchTxDMADataStruct
  985. {
  986.     struct PeleAsynchTxDMADataStruct    *pNextTxDMAData;// Pointer to next descriptor.
  987.     struct PeleFWIMDataStruct    *pPeleFWIMData;            // Pointer to Pele FWIM data.
  988.     PeleDMAPtr                    pDMA;                    // Logical pointer to descriptor
  989.     Ptr                            pDMAPhysical;            // Physical pointer to descriptor.
  990. };
  991. typedef struct PeleAsynchTxDMADataStruct
  992.                                 PeleAsynchTxDMAData,
  993.                                 *PeleAsynchTxDMADataPtr;
  994.  
  995. // Private data structure for PeleFWIM - one per Pele
  996.  
  997. struct PeleFWIMDataStruct
  998. {
  999.     // Some fields within this struct will be physically addressed by commands in a PCL program.
  1000.     // We will only map the first page of this struct physically, so these fields must be within
  1001.     // the first page.  So don't rearrange this part of the struct.
  1002.     
  1003.     DCLCommandPtr                pDCLInterruptTail[kNumDMAChannels];    // Tails of DCL interrupt queues.
  1004.     volatile UInt32                asynchTxDoneFlag;        // Flag indicating that asynchronous transmit has finished.
  1005.     UInt32                        asynchRxOverflowFlag;    // Flag indicating an overflow in asynch receive.
  1006.  
  1007.     // Nothing below this line will be accessed via physical addresses
  1008.     
  1009.     PhysicalAddress                fwimDataPhys;            // Physical address of this struct
  1010.     IOPreparationTable            fwimDataIOPrep;            // ioPrep data for this struct
  1011.     FWIMID                        fwimID;                    // ID for this FWIM
  1012.     RegEntryID                    FWIMRegEntryID;            // Name registry ID for TI card.
  1013.     UInt32                        generation;                // Current bus generation number.
  1014.     Boolean                        generationValid;        // Generation number is valid.
  1015. // Could probably remove this
  1016.     Boolean                        root;                    // True if we're root.
  1017.     TimerID                        resetDebounceTimerID;    // TimerID for debouncing resets
  1018.     Boolean                        resetDebounceTimerSet;    // Flag indicating the above timer is running
  1019.     TimerID                        requestTimeoutTimerID;    // TimerID to indicate timeout of a read/write request
  1020.     Boolean                        requestTimeoutTimerSet;    // Flag indicating the above timer is running
  1021.     FWDeferredTaskID            busResetDeferredTaskID;    // Deferred task ID for handling bus resets.
  1022.     Boolean                        busResetDTScheduled;    // True if we've scheduled a DT to handle bus resets.
  1023.     FWDeferredTaskID            asynchReceiveDeferredTaskID;    // Deferred task ID for handling received asynch packets.
  1024.     Boolean                        asynchReceiveDTScheduled;    // True if we've sceduled a DT to handle received asynch packets.
  1025.     FWDeferredTaskID            isochReceiveDeferredTaskID;    // Deferred task ID for handling received isoch packets.
  1026.     Boolean                        isochReceiveDTScheduled;    // True if we've sceduled a DT to handle received isoch packets.
  1027.     FWDeferredTaskID            isochTransmitDeferredTaskID;    // Deferred task ID for handling transmitted isoch packets.
  1028.     Boolean                        isochTransmitDTScheduled;    // True if we've sceduled a DT to handle transmitted isoch packets.
  1029.     FWDeferredTaskID            miscInterruptDeferredTaskID;    // Deferred task ID for handling misc interrupts.
  1030.     Boolean                        miscInterruptDTScheduled;    // True if we've sceduled a DT to handle misc interrupts.
  1031.     UInt32                        miscInterrupt;            // Miscellaneous interrupt to deal with
  1032.     FWIMCommandParamsPtr        pPendingFWIMCommand;    // Pending FWIM command.
  1033.     OSStatus                    pendingFWIMCommandStatus;    // Internal status of pending FWIM command.
  1034.     FWIMCommandParamsPtr        pPendingFWIMResponseCommand;    // Pending FWIM response command.
  1035.     UInt32                        transactionLabel;        // Label used for current transaction
  1036.     UInt32                        tCode;                    // TCode for current transaction.
  1037. // Is this used?
  1038.     DCLCommandPtr                pCurrentDCLCommand;        // Pointer to current DCL command.
  1039.     InterruptSetMember            interruptSetMember;
  1040.     void                        *oldInterruptRefCon;
  1041.     InterruptHandler            oldInterruptHandler;
  1042.     InterruptEnabler            interruptEnabler;
  1043.     InterruptDisabler            interruptDisabler;
  1044.     PeleRegistersPtr            pPeleRegisters;            // Register file
  1045.     Ptr                            asynchBuf[kAsynchRxBufs];    // Non-isoch
  1046.     Ptr                            asynchBufPhys[kAsynchRxBufs];    // Physical addrs
  1047.  
  1048.     PeleDMA                        *asynchXmitDMA;            // two for transmit
  1049.     Ptr                            asynchXmitDMAPhys;        // Physical addrs
  1050.     PeleAsynchTxDMADataPtr        pNextAsynchTxDMAData;    // Pointer to next active asynch transmit PCL to process.
  1051.     PeleAsynchTxDMADataPtr        pLastAsynchTxDMAData;    // Pointer to last active asynch transmit PCL.
  1052.     PeleAsynchTxDMADataPtr        asynchTxDoneDMASegment;    // PCL segment to deal with finished asynch transmit.
  1053.     PeleAsynchTxDMADataPtr        AsynchTxDMADataList;    // List of data records for asynch transmit PCLs.
  1054.  
  1055.     PeleDMA                        *asynchDMA;                // asynch DMA loop /zzz rename
  1056.     PeleAsynchRxDMADataPtr        pNextAsynchRxDMAData;    // Next asynch receive DMA to process.
  1057.     PeleAsynchRxDMADataPtr        pLastAsynchRxDMAData;    // Last available asynch receive DMA.
  1058.     PeleAsynchRxDMADataPtr        pStartAsynchRxDMAData;    // Asynch receive PCL to start receive program.
  1059.     UInt32                        numAsynchRxDMAsPrimed;    // Number of receive PCLs primed.
  1060.     PeleAsynchRxDMADataPtr        asynchRxOverflowDMASegment;    // DMA segment to deal with asynch receive overflow.
  1061.     Ptr                            asynchDMAPhys;            // Physical addrs
  1062.     PeleAsynchRxDMADataPtr        asynchRxDMADataList;    // List of data records for asynch receive PCLs.
  1063.  
  1064.     Ptr                            asynchXmitBuf;            // For Asynch xmit
  1065.     Ptr                            asynchXmitBufPhys;        // Physical
  1066.     IOPreparationTable            ioPrep;                    // For VM
  1067.     PhysicalAddress                physAddrs[kAsynchRxBufs+20];    // Page table - fix this
  1068. //rename
  1069.     PeleIsochPortDataPtr        lynxIsochPortDataList[kNumDMAChannels];    // List of isoch port data records.
  1070.     UInt32                        pageSize,                // Physical page size and shift for VM.
  1071.                                 pageShift;
  1072. //unused?
  1073.     UInt32                        bitBucket;                // Bit bucket to dump stuff into.
  1074.     TimerID                        delayedResetTimerID;    // (temporary hack)
  1075.     Boolean                        delayedResetTimerSet;    // Flag indicating the above timer is running
  1076.     UInt8                        lastPhyReg0;            // Last known value of PHY register zero
  1077.     UInt32                        lastPhyControl;            // Last known value of PHY control register
  1078. };
  1079. typedef struct PeleFWIMDataStruct        PeleFWIMData, *PeleFWIMDataPtr;
  1080.  
  1081. // The DBDMA Pool is actually an allocate-once memory source for descriptors.
  1082. // We allocate one large block and then break it up into DBDMA descriptors.
  1083. // We can allocate more large blocks if required.  Blocks are released when
  1084. // a DBDMA program is no longer needed.
  1085.  
  1086. enum
  1087. {
  1088.     kDMAPoolSize                = 480,
  1089.     kDMAAlignmentMask            = 0xFFFFFFF0
  1090. };
  1091.  
  1092. typedef struct PeleDMAPoolDataStruct
  1093.                                 PeleDMAPoolData,
  1094.                                 *PeleDMAPoolDataPtr;
  1095. struct PeleDMAPoolDataStruct
  1096. {
  1097.     PeleDMAPoolDataPtr            pNextPeleDMAPoolData;    // Link to next PCL pool data record.
  1098.     UInt32                        nextFreeDMA;            // Next free PCL in pool.
  1099.     PeleDMAPtr                    alignedDMAPoolBase;        // 128-byte-aligned PCL pool base address.
  1100.     UInt32                        alignedDMAPoolBasePhys;    // Physical addr of same
  1101.     LogicalAddress                poolAllocatedAddress;    // Actual allocated address
  1102.     IOPreparationTable            ioPrep;                    // For VM
  1103.     PhysicalAddress                physAddrs[20];            // warning, arbitrary constant
  1104.     PeleDMA                        dmaPoolDummy[kDMAPoolSize];    // Space for PCL pool array.
  1105. };
  1106.  
  1107. // We create one of these for each DCL to hold compiler private information:
  1108.  
  1109. struct PeleDCLCompilerDCLDataStruct
  1110. {
  1111.     PeleDMAPtr                    pDMA;                    // pointer to (first) descriptor
  1112.     PhysicalAddress                pDMAPhys;                // Physical address of same
  1113. };
  1114. typedef struct PeleDCLCompilerDCLDataStruct
  1115.                                 PeleDCLCompilerDCLData,
  1116.                                 *PeleDCLCompilerDCLDataPtr;
  1117.  
  1118. // As we compile DCLs into DBDMA, this structure keeps track of general
  1119. // information.  There is one of these for each program being compiled.
  1120.  
  1121. struct PeleDCLCompilerEngineDataStruct
  1122. {
  1123.     PeleFWIMDataPtr                pPeleFWIMData;            // Our FWIM data.
  1124.     PeleDMAPtr                    pStartDMA;                // Pointer to first DBDMA in compiled program.
  1125.     PeleDMAPoolDataPtr            pPeleDMAPoolDataList;    // List of DBDMA pools allocated for this copmiled program.
  1126.     UInt32                        engineGeneration;        // For faster lookups
  1127.     IOPreparationTable            ioPrep;                    // For all buffers/etc
  1128.     PhysicalAddress                *physAddrs;                // Page table (of sorts)
  1129.     PeleDCLCompilerDCLDataPtr    pPeleDCLCompilerDCLData;// Base of compiler data list
  1130. };
  1131. typedef struct PeleDCLCompilerEngineDataStruct
  1132.                                 PeleDCLCompilerEngineData,
  1133.                                 *PeleDCLCompilerEngineDataPtr;
  1134.  
  1135. // As we compile DCLs into DBDMA, this structure keeps track of DBDMA-oriented
  1136. // information.  There is one of these for each program being compiled.
  1137.  
  1138. struct PeleDMABuildStateStruct
  1139. {
  1140.     PeleFWIMDataPtr                pPeleFWIMData;            // Our FWIM data.
  1141.     PeleDCLCompilerEngineDataPtr
  1142.                                 pPeleDCLCompilerEngineData;
  1143.     UInt32                        dmaChannelNum;            // DMA channel number we're building for.
  1144.     PeleDMAPoolDataPtr            pPeleDMAPoolDataList;    // List of DBDMA pools allocated for this build.
  1145.     UInt32                        isochChannelNum;        // Isochronous channel number.
  1146.     UInt32                        *pLastBranch;            // unfilled branch from last DBDMA
  1147. };
  1148. typedef struct PeleDMABuildStateStruct    PeleDMABuildState, *PeleDMABuildStatePtr;
  1149.  
  1150.  
  1151. #if PRAGMA_ALIGN_SUPPORTED
  1152. #pragma options align=reset
  1153. #endif
  1154.  
  1155. #if PRAGMA_IMPORT_SUPPORTED
  1156. #pragma import off
  1157. #endif
  1158.  
  1159. #ifdef __cplusplus
  1160. }
  1161. #endif
  1162.  
  1163. #endif /* __PELEFWIM__ */
  1164.